package cn.wolfcode.luowowo.mgrsite.job;

import cn.wolfcode.luowowo.article.domain.Strategy;
import cn.wolfcode.luowowo.article.domain.StrategyDetail;
import cn.wolfcode.luowowo.article.service.IStrategyDetailService;
import cn.wolfcode.luowowo.article.vo.StrategyStatisPersistenceVO;
import cn.wolfcode.luowowo.cache.domain.StrategyStatisVO;
import cn.wolfcode.luowowo.cache.service.IStrategyStatisRedisService;
import cn.wolfcode.luowowo.cache.util.RedisKeys;
import cn.wolfcode.luowowo.member.util.BeanUtil;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RedisDataPersistenceJob {
    @Reference
    private IStrategyStatisRedisService strategyStatisRedisService;
    @Reference
    private IStrategyDetailService strategyDetailService;
    public void doWork() {
        System.out.println("---------------");
        //攻略统计数据的持久化
        //获取所有攻略统计数据vo对象
        List<StrategyStatisVO> list = strategyStatisRedisService.listStrategyStatisVo(RedisKeys.STRATEGY_STATIC_VO.join("*"));
        for (StrategyStatisVO vo:list){
            StrategyStatisPersistenceVO pvo = new StrategyStatisPersistenceVO();
            BeanUtil.copyProperty(pvo,vo);
            strategyDetailService.updateStatisVO(pvo);
        }
    }
}
